{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": 1,
   "metadata": {},
   "outputs": [],
   "source": [
    "import pandas as pd"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "metadata": {},
   "outputs": [],
   "source": [
    "import matplotlib.pyplot as plt"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 3,
   "metadata": {},
   "outputs": [],
   "source": [
    "%matplotlib inline"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 4,
   "metadata": {},
   "outputs": [],
   "source": [
    "ri = pd.read_csv('police.csv')"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 5,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "(91741, 15)"
      ]
     },
     "execution_count": 5,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "ri.shape"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 10,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "NaN                                                         88545\n",
       "Incident to Arrest                                           1219\n",
       "Probable Cause                                                891\n",
       "Inventory                                                     220\n",
       "Reasonable Suspicion                                          197\n",
       "Protective Frisk                                              161\n",
       "Incident to Arrest,Inventory                                  129\n",
       "Incident to Arrest,Probable Cause                             106\n",
       "Probable Cause,Reasonable Suspicion                            75\n",
       "Incident to Arrest,Inventory,Probable Cause                    34\n",
       "Probable Cause,Protective Frisk                                33\n",
       "Incident to Arrest,Protective Frisk                            33\n",
       "Inventory,Probable Cause                                       22\n",
       "Incident to Arrest,Reasonable Suspicion                        13\n",
       "Inventory,Protective Frisk                                     11\n",
       "Incident to Arrest,Inventory,Protective Frisk                  11\n",
       "Protective Frisk,Reasonable Suspicion                          11\n",
       "Incident to Arrest,Probable Cause,Protective Frisk             10\n",
       "Incident to Arrest,Probable Cause,Reasonable Suspicion          6\n",
       "Incident to Arrest,Inventory,Reasonable Suspicion               4\n",
       "Inventory,Reasonable Suspicion                                  4\n",
       "Inventory,Probable Cause,Reasonable Suspicion                   2\n",
       "Inventory,Probable Cause,Protective Frisk                       2\n",
       "Incident to Arrest,Protective Frisk,Reasonable Suspicion        1\n",
       "Probable Cause,Protective Frisk,Reasonable Suspicion            1\n",
       "Name: search_type, dtype: int64"
      ]
     },
     "execution_count": 10,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "ri.search_type.value_counts(dropna=False)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 11,
   "metadata": {},
   "outputs": [],
   "source": [
    "ri['frisk']=ri.search_type.str.contains('Protective Frisk')"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 14,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "NaN      88545\n",
       "False     2922\n",
       "True       274\n",
       "Name: frisk, dtype: int64"
      ]
     },
     "execution_count": 14,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "ri['frisk'].value_counts(dropna=False)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 15,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "0.08573216520650813"
      ]
     },
     "execution_count": 15,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "274/(274+2922)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 16,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "NaN      88545\n",
       "False     2922\n",
       "True       274\n",
       "Name: frisk, dtype: int64"
      ]
     },
     "execution_count": 16,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "ri.frisk.value_counts(dropna=False)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 18,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "0.08573216520650813"
      ]
     },
     "execution_count": 18,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "ri.frisk.mean()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": []
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.6.5"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 2
}
